package com.nianzhen.student.fra;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.nianzhen.db.Jobitem;
import com.nianzhen.recruitment.R;

public class JobAdapter extends BaseAdapter {

	private ArrayList<Jobitem> names;
	private Context context;
	private LayoutInflater layoutInflater;

	public JobAdapter(Context context, ArrayList<Jobitem> name) {
		this.names = name;
		this.context = context;
		this.layoutInflater = LayoutInflater.from(context);

	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return names.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return names.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		// TODO Auto-generated method stub
		School_item vHelper = new School_item();
		if (arg1 == null) {
			arg1 = layoutInflater.inflate(R.layout.job_list_item, null);
			vHelper.company = (TextView) arg1.findViewById(R.id.job_company);
			vHelper.job = (TextView) arg1.findViewById(R.id.job_name);
			arg1.setTag(vHelper);
		} else {
			vHelper = (School_item) arg1.getTag();
		}
		vHelper.company.setText(names.get(arg0).getCompany());
		vHelper.job.setText(names.get(arg0).getJob());
		return arg1;
	}

	private class School_item {
		TextView company;
		TextView job;
	}

}
